package uk.co.hs.dao.web.admin;

import java.util.List;

import org.springframework.stereotype.Repository;

import uk.co.hs.dao.generic.UtilisoftGenericDao;
import uk.co.hs.domain.web.WebUrl;

@Repository("hs_webUrlDao")
public class WebUrlDao extends UtilisoftGenericDao<WebUrl, Long>
{
  @SuppressWarnings("unchecked")
  public List<WebUrl> getAllSortedByDescription()
  {
    return getSession().createQuery("FROM WebUrl ORDER BY description ASC").list();
  }

  @SuppressWarnings("unchecked")
  public List<WebUrl> getAllSortedByUrl()
  {
    return getSession().createQuery("FROM WebUrl WHERE forwardableByDefault = true ORDER BY url ASC").list();
  }

  public WebUrl getByUrl(String aUrl)
  {
    return (WebUrl) getSession().createQuery("FROM WebUrl webUrl WHERE webUrl.url = :url").setParameter("url", aUrl).uniqueResult();
  }
}
